package ipebg.mzk.provider.system.dao;

import ipebg.mzk.common.core.dao.impl.DBDao;
import ipebg.mzk.facade.entity.MsAccessCountRecord;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;

@Repository("msAccessCountRecordDao")
public class MsAccessCountRecordDao extends DBDao<MsAccessCountRecord>{

	private static Log log = LogFactory.getLog(MsAccessCountRecordDao.class);
	public MsAccessCountRecordDao(){
		super(MsAccessCountRecord.class);
	}
	
	public Long findAccessCountByDays(String beginDay, String endDay,String accessType) throws Exception {
		Long count = 0L;
		StringBuilder sbHql = new StringBuilder();
		try {
			sbHql.append("SELECT COUNT(*)  FROM MsAccessCountRecord WHERE 1=1 ");
			if (beginDay != null) {
				sbHql.append(" and recordDay >='" + beginDay + "'");
			}
			if (endDay != null) {
				sbHql.append(" and recordDay <='" + endDay + "'");
			}
			if(accessType!=null){
				sbHql.append(" and recordType ='" + accessType + "'");
			}
			count=getCount(sbHql.toString(), null);

		} catch (Exception e) {
			throw e;
		}
		return count;
	}
}


